package com.example.clientbwic.mapper;

import com.example.clientbwic.entity.Bid;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 86150
 * @Date: 2024/4/13
 * @Description: com.example.clientbwic.mapper
 */
@Mapper
public interface BidMapper {
    @Results(
            @Result(property = "market_value", column = "bid_market_value")
    )
    @Select("SELECT * FROM bid LEFT JOIN bwic ON bid.bwic_id = bwic.bwic_id WHERE bwic.bwic_id = #{bwicId} LIMIT 50")
    List<Bid> getBidsByBwicId(String bwicId);

    @Select("SELECT COUNT(*) FROM bid WHERE bwic_id = #{bwicId}")
    String getBidsCountByBwicId(String bwicId);
    @Select("SELECT * FROM bid WHERE bwic_id = #{bwicId} AND bid.bid_successful = 'Y' LIMIT 50")
    Bid getSuccessBidByBwicId(String bwicId);
}
